def solution(n, array):
    # Edit your code here
    res = []
    for i in range(n):
        for j in range(i + 1, len(array)+1):
            # print(array[i:j])
            res.append(len(array[i:j])* min(array[i:j]))
    return max(res)


if __name__ == "__main__":
    # Add your test cases here

    print(solution(5, [1, 2, 3, 4, 5]) == 9)
    print(solution(6, [5,4,3,2,1,6]) == 9)